package com.mycompany.testcases.chee;


import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import com.mycompany.project.client.chee.GPSData;

public class GPSDataTest{

private static GPSData gpsdata = new GPSData();
	
	@Before
	public void initList()
	{
		//clear both list
		for(int i=0;i<gpsdata.getGpsList().size();i++)
		{
			gpsdata.getGpsList().get(i).clear();
		}
		gpsdata.getKeyList().clear();
	}
	
	@Test
	public void test1() {
		//test for unique keys 
		//we'll use an int array storing up to 100 numbers
		int []keys = new int[100];
		for(int i=0;i<100;i++)
		{
			keys[i] = gpsdata.getNewUniqueKey();
		}
		//next we'll check that all keys in the array are unique
		for(int i=0;i<100;i++)
		{
			//compare all keys and make sure they're unique
			for(int j=0;j<100;j++)
			{
				if(i != j)//compare only keys other than itself
					assert keys[i] != keys[j];
			}
		}
	}
	@Test
	public void test2() {
		//test for unique x and y position 
		//we'll use an int array list storing up to 1000 positions
		ArrayList<int[]> keys = new ArrayList<int[]>();
		for(int i=0;i<500;i++)
		{
			keys.add(GPSData.getUniqueXY());
		}
		//next we'll check that all position in the array are unique
		for(int i=0;i<keys.size();i++)
		{
			//compare all positions and make sure they're unique
			for(int j=0;j<keys.size();j++)
			{
				if(i != j){//compare only keys other than itself
					assert keys.get(i) != keys.get(j);
				}
			}
		}
	}
	
	

}
